﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

#include <qmodbustcpclient.h>
#include <QTimer>
#include <qlist.h>

#include "cglasseffect.h"

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public CglasseFfect
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private:
    Ui::MainWindow *ui;


private:
    QModbusTcpClient *my_client;   //modbustcp客户端
    QTimer *my_timer;  //modbus连接定时检测

    QList<int> modbus_data;  //保持寄存器值

public:
    //int resolution_ratio = 1920;
private:
    void Write_modbus_tcp_HoldingRegisters(int value, int star_add,int number);
    void read_modbus_tcp_HoldingRegisters(int start_add,quint16 numbers ,int Server_ID);
    bool Connect_modbus();
    void showEvent(QShowEvent *ev);

public slots:

    void StateChanged_Slot();

    void ReadReady_InputRegisters();

    //modbus 发送数据槽
    void SendChannel_Slot();
    void SendNumber_Slot();
    void SendSpacing_Slot();
    void StartMotor_Slot();
    void StopMotor_Slot();
    void AddOne_Slot();
    void ReConnect();

    //定时器
    void onConnectTimerTimeout();   //modbus连接

};

#endif // MAINWINDOW_H
